package org.linloong.modules.apis.monitor.enums;


import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum HabitatEnum {
    WIND_DIRECTION      ("windDirection",       "风向",        "°"),
    WIND_SPEED          ("windSpeed",           "风速",        "m/s"),
    AIR_TEMPERATURE     ("temperature",         "温度",        "℃"),
    AIR_HUMIDITY        ("airHumidity",         "湿度湿度",     "%"),
    HOUR_RAINFALL       ("hourRainfall",        "小时雨量",     "mm"),
    ATMOSPHERIC_PRESSURE("atmosphericPressure", "气压",        "hPa"),
    SOIL_WATER_PCT      ("soilWaterPct",        "土壤含水率2",  "%"),
    SOIL_MOISTURE       ("soilMoisture",        "土壤湿度3",     "%"),
    MAX_SUNSHINE        ("maxSunshine",         "最大光照",     "Lux"),

    BATTERY_VOLTAGE     ("batteryVoltage",      "电池电压", "V"),
    CO                  ("co",                  "CO",      "ppb"),
    MIN_RAINFALL        ("minRainfall",         "雨量",     "mm"),
    NO2                 ("no2",                 "NO2",      "ppb"),
    O3                  ("o3",                  "O3",       "ppb"),
    PM10                ("pm10",                "PM10",     "ug/m³"),
    PM25                ("pm25",                "PM2.5",    "ug/m³"),
    SO2                 ("so2",                 "SO2",      "ppb"),
    SOIL_MOISTURE_2     ("soilMoisture2",       "土壤湿度2", "%"),
    SOIL_MOISTURE_3     ("soilMoisture3",       "土壤湿度3", "%"),
    SOIL_SALINITY       ("soilSalinity",        "土壤盐分", "us/cm"),
    SOIL_TEMPERATURE_1  ("soilTemperature1",    "土壤温度1", "℃"),
    SOIL_TEMPERATURE_2  ("soilTemperature2",    "土壤温度2", "℃"),
    SOIL_TEMPERATURE_3  ("soilTemperature3",    "土壤温度3", "℃"),
    TOTAL_RADIATION     ("totalRadiation",      "总辐射",   "w/m²"),
    ULTRAVIOLET_RAY     ("ultravioletRay",      "紫外线",   "w/m²"),
    ;

    /**
     * 英文代码（对应变量名/字段名）
     */
    private final String code;

    /**
     * 中文名称
     */
    private final String name;

    /**
     * 物理单位
     */
    private final String unit;

    /**
     * 根据 code 反查枚举（快速映射）
     */
    public static HabitatEnum ofCode(String code) {
        for (HabitatEnum e : values()) {
            if (e.code.equalsIgnoreCase(code)) {
                return e;
            }
        }
        return null;
    }
}
